# -*- coding: utf-8 -*-
import sys

class LogOutput():
    def __init__(self, logfile):
        self.stdout = sys.stdout
        self.log = open(logfile, 'w')

    def write(self, text):
        self.stdout.write(text)
        self.log.write(text)
        self.log.flush()

    def close(self):
        self.stdout.close()
        self.log.close()
        
def StrToBool(str):
    return str.lower() in ["true", "1"]

def ConvertEncodingName(src):
    if src == u"UTF-8":
        return u"utf-8"
    elif src == u"utf-8":
        return u"UTF-8"
    elif src == u"UTF-16BE":
        return u"utf_16_be"
    elif src == u"utf_16_be":
        return u"UTF-16BE"
    elif src == u"UTF-16LE":
        return u"utf_16_le"
    elif src == u"utf_16_le":
        return "UTF-16LE"
    elif src == u"UTF-32BE":
        return u"utf_32_be"
    elif src == u"utf_32_be":
        return u"UTF-32BE"
    elif src == u"UTF-32LE":
        return u"utf_32_le"
    elif src == u"utf_32_le":
        return u"UTF-32LE"
    elif src == u"CP1251":
        return u"cp1251"
    elif src == u"cp1251":
        return u"CP1251"